package com.wyj.core;

import com.wyj.controller.IndexServlet;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.LifecycleListener;
import org.apache.catalina.connector.Connector;
import org.apache.catalina.core.AprLifecycleListener;
import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.Tomcat;

import javax.servlet.ServletException;
import java.util.logging.Logger;

/**
 * TODO:
 * @author wyj
 * @date 2021/12/4 15:34
 **/
public class SpringApplication {
    private static final Logger LOGGER= Logger.getLogger(SpringApplication.class.getName());

    public static void run(){
    //    创建tomcat并启动
        createTomcatWebServer();
    }

    private static void createTomcatWebServer()  {
        Tomcat tomcat = new Tomcat();
        tomcat.setPort(8090);
        try {
            tomcat.addWebapp("/","E://temp");
            tomcat.start();
            tomcat.getServer().await();
        } catch (LifecycleException e) {
            LOGGER.info("createTomcatWebServer error:");
            e.printStackTrace();

        } catch (ServletException e) {
            e.printStackTrace();
        }
    }
}
